#ifndef QSQLITE_H
#define QSQLITE_H

#include <QObject>
#include <QDebug>

#include "qdatasession.h"

// sqlite 数据库连接
class QSqlite :public QLimitSession
{
public:
    explicit QSqlite(QString dbName,QString user="",QString password=""):QLimitSession(){
        auto connectionName = QSqlDatabase::defaultConnection;
        if(!QSqlDatabase::contains(connectionName)){
            this->connection = QSqlDatabase::addDatabase("QSQLITE",connectionName);
        }else{
            this->connection = QSqlDatabase::database(connectionName);
        }
        this->connection.setDatabaseName(dbName);
        if(!user.isEmpty()){
            this->connection.setUserName(user);
        }
        if(password.isEmpty()){
            this->connection.setPassword(password);
        }
    }
};

#endif // QSQLITE_H
